package com.my.study.config;

import com.my.study.bean.Car;
import com.my.study.bean.Dog;
import com.my.study.bean.People;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * @author Carlos
 * @version 1.0
 * @Description
 * <p>
 * @ConditionalOnBean(Car.class) 需要Car已经注入到容器中了！！
 * @ConditionalOnClass(Car.class) 只需要类路径中存在Car这个类就可以！！
 *
 * @date 2021/11/7 21:54
 **/
@Configuration
@ConditionalOnProperty(prefix = "people", name = "enable", havingValue = "true")
@Import(Dog.class)
public class ConditionalConfig {

    @Bean
    public Car car() {
        return new Car();
    }

    @ConditionalOnBean(Car.class)
//    @ConditionalOnClass(Car.class)
    @Bean
    public People people() {
        return new People();
    }


}
